<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
    <title>9-24注册测试</title>
    <script>
        function register() {
            $.ajax({
                url: 'http://localhost:3000/api/register',
                type: "post",
                data: {
                    userName: $(" #userName ").val(), userPwd: $('#userPwd').val()
                },
                success: function (message) {
                    if (message = 'ok') {
                        alert('注册成功!')
                    } else {
                        alert('注册失败!')
                    }
                }
            })
        }
    </script>
</head>

<body>
    <form action="">
        <input type="text" name="userName" id="userName">
        <input type="password" name="userPwd" id="userPwd">
        <input type="button" value="注册" onclick="register()">
    </form>
</body>

</html>